<html ui-size=normal>
<head>
<style>

@import url(node_modules/sciter-fontawesome/src/fontawesome.css);
@import url(css/controls.css);

html {
    background: color(panel);
    color: color(panel-text);
}

html[ui-size=compact] {
    font-size: 9pt;
}

body {
    flow: horizontal-flow;
}

.hbox {
    width: max-content;
    height: 310dip;

    flow: vertical;

    // spacing of elements in flow
    border-spacing: 1.0em;

    border: 1dip solid gray;
    border-right: none;

    padding: 1em;
}

.hbox:last-child {
    border: 1dip solid gray;
}

p {
    margin: 0;
    text-align: center;
}

checkbox#checkbox-label {
    flow: stack;
}

checkbox#checkbox-label > caption {
    display:block;
    visibility:hidden;
}

checkbox#checkbox-label:checked > caption.true {
    visibility:visible;
}

checkbox#checkbox-label:not(:checked) > caption.false {
    visibility:visible;
}

select[type="list"] {
    min-height: 25dip;
}

select[type="list"]#table {
    flow: table;
    width: 100%;
    height: 60dip;
}

select[type="list"]#table option {
    flow: table-row;
}

select[type="tree"] {
    width: max-content;
}

@import url("css/std-menu.css");
@import url("css/menu-bar.css");

menu.bar {
    width: 280dip;
}

button.context-menu {
    context-menu: selector(menu#context);
}

plaintext {
    width: *;
    height: 100dip;
}

plaintext#lorem {
    width: 100%;
}

textarea,
htmlarea {
    width: 100dip;
}

video {
    width: 160dip;
    height: 90dip;
}

</style>
<script type="module">

import * as Dialogs from "js/dialogs.js";

document.on("ready", function() {
    // get console from iframe parent
    //logger.setConsole();

    // capture unhandled exceptions
    //logger.capture();

    loadcss();

    // set load css
    document.on("click", "button#plaintext", loadcss);

    // set output time
    const time = document.$("output[type=time-local]");

    time.value = new Date();

    time.timer(1000, function() {
        time.value = new Date();
        return true;
    });

    const form = document.$("form#output");

    form.value = {
        field1: "hello",
        field2: "world",
        field3: 1,
    };
});

// set dialog buttons on click event
document.on("click", "button", function(event, element) {
    let value;

    switch (element.id) {
        case "info":
            value = Window.this.modal(Dialogs.dialogInfo);
            break;

        case "alert":
            value = Window.this.modal(Dialogs.dialogAlert);
            break;

        case "error":
            value = Window.this.modal(Dialogs.dialogError);
            break;

        case "question":
            value = Window.this.modal(Dialogs.dialogQuestion);
            break;

        case "file":
            value = Window.this.selectFile("Select file");
            break;

        case "folder":
            value = Window.this.selectFolder("Select folder");
            break;

        default:
            console.error("unknown element");
            break;
    }

    console.log("return value:", value);
});

/**
 * Load file into plaintext
 */
async function loadcss() {
    const plaintext = document.$("plaintext");

    try {
        const r = await fetch("css/window.css");

        if (r.ok) {
            plaintext.value = r.text();
            return;
        }
    }
    catch (error) {
        console.error(error);
        plaintext.value = "url not found";
    }
}

</script>
</head>
<body>
    <div .hbox>
        <p>buttons</p>
        <button>Do it!</button>
        <button role="default-button">Default</button>
        <button disabled>Disabled</button>
        <button .success>Success</button>
        <button .warning>Warning</button>
        <button .danger>Danger</button>
    </div>

    <div .hbox>
        <p>editbox</p>
        <editbox value="foo" placeholder="input with content" maxlength=6 filter="a~z" spellcheck="yes" />
        <editbox placeholder="input text here" />
        <editbox nullable placeholder="nullable" />
        <editbox disabled value="disabled" />
        <input|password placeholder="password" password-char="*" />
        <!-- https://github.com/c-smile/sciter-js-sdk/blob/main/docs/md/behaviors/behavior-masked-edit.md -->
        <input|masked mask="(###) ### - ####" />
        <!-- not working
        <input type="currency" placeholder="currency" />
        <input type="url" placeholder="url" />
        -->
    </div>

    <div .hbox>
        <p>input|number</p>
        <input|number value="42" step="1" min="0" max="999" placeholder="number1" />
        <input|number step="1" min="0" max="999" placeholder="number2" />
        <input|number disabled step="1" min="0" max="999" />
        <input|decimal value="42.13" />
        <input|integer value="42" />
    </div>

    <div .hbox>
        <p>radio</p>
        <!-- as="string | integer | float | numeric | auto" -->
        <radio (rgroup) checked value="true" as="string">Yes</radio>
        <radio (rgroup) value="false" as="string">No</radio>
        <radio (rgroup) value="null" as="string">Undefined</radio>

        <radio (rgroupd) disabled checked value="a">Disabled (Checked)</radio>
        <radio (rgroupd) disabled value="b">Disabled</radio>
    </div>

    <div .hbox>
        <p>checkbox</p>
        <checkbox checked>Checked</checkbox>
        <checkbox>Unchecked</checkbox>
        <checkbox mixed>Mixed</checkbox>

        <checkbox disabled checked value="a">Disabled (Checked)</checkbox>
        <checkbox disabled value="b">Disabled</checkbox>

        <checkbox #checkbox-label checked>
            <caption .true>checked state</caption>
            <caption .false>unchecked state</caption>
        </checkbox>
    </div>

    <div .hbox>
        <p>toggle</p>
        <toggle (foo) checked>
            <option>No</option>
            <option>Yes</option>
        </toggle>

        <hr />
        no label
        <toggle (bar) />

        <hr />
        group
        <toggle|radio(group) value="A" />
        <toggle|radio(group) value="B" />
        <toggle|radio(group) value="C" />
    </div>

    <div .hbox>
        <p>select|switch</p>
        <select|switch>
            <option>Left</option>
            <option>Center</option>
            <option>Right</option>
        </select>
    </div>

    <div .hbox>
        <p>select|dropdown</p>
        <select|dropdown novalue="dropdown">
            <option>Apple</option>
            <option>Apricot</option>
            <option>Currant</option>
            <option>Grapefruit</option>
            <option>Peach</option>
            <option>Pomegranate</option>
            <option>Tamarind</option>
        </select>

        <select|dropdown editable>
            <option>Apple</option>
            <option>Apricot</option>
            <option>Currant</option>
            <option>Grapefruit</option>
            <option>Peach</option>
            <option>Pomegranate</option>
            <option>Tamarind</option>
        </select>

        <select|dropdown novalue="disabled" disabled>
            <option>Apple</option>
            <option>Apricot</option>
            <option>Currant</option>
            <option>Grapefruit</option>
            <option>Peach</option>
            <option>Pomegranate</option>
            <option>Tamarind</option>
        </select>

        <select|dropdown>
            <option>One</option>
            <optgroup label="Group 1">
                <option>Two</option>
                <option.toset>Three</option>
                <option>Four</option>
            </optgroup>
            <optgroup>
                <caption>Group 2</caption>
                <option>Five</option>
                <option>Six</option>
                <option>Seven</option>
                <option>Eight</option>
            </optgroup>
            <option>Nine</option>
            <option>Ten</option>
            <option>Eleven</option>
            <option>Twelve</option>
        </select>
    </div>

    <div .hbox>
        <p>select|list</p>
        <select|list multiple size=5>
            <option>Apple</option>
            <option selected>Apricot</option>
            <option>Currant</option>
            <option selected>Grapefruit</option>
            <option>Peach</option>
            <option>Pomegranate</option>
            <option>Tamarind</option>
        </select>
        <select|list multiple="checkmarks" size=5 dir="rtl">
            <option>Apple</option>
            <option checked>Apricot</option>
            <option checked>Currant</option>
            <option>Grapefruit</option>
            <option>Peach</option>
            <option>Pomegranate</option>
            <option>Tamarind</option>
        </select>
        <select|list #table size=3>
            <option value="1">
                <span>1</span>
                <span>Fox</span>
            </option>
            <option value="2">
                <span>2</span>
                <span>Bravo</span>
            </option>
            <option value="3">
                <span>3</span>
                <span>Alpha</span>
            </option>
        </select>
    </div>

    <div .hbox>
        <p>select|tree</p>
        <select|tree multiple="checkmarks" treelines>
            <option expanded>
                <caption>Fruits</caption>
                <option value="1" checked>Apple</option>
                <option value="2">Apricot</option>
                <option value="3" checked>Currant</option>
            </option>
            <option>
                <caption>Veggies</caption>
                <option value="4">Cabbage</option>
                <option value="5">Broccoli</option>
                <option value="6">Chicory</option>
            </option>
        </select>
    </div>

    <div .hbox>
        <p>progress</p>
        indefinite: <progress />
        0: <progress value=0 max=100 />
        50.2/100 <progress value=50.2 max=100 />
        100/100.8: <progress value=100 max=100.8 />
    </div>

    <div .hbox>
        <p>slider</p>
        <slider min=0 max=100 value=50 />
        <slider disabled min=0 max=100 value=50 />
        <slider min=0 max=100 value=50 buddy="p1a-buddy" step="3" /><b id="p1a-buddy">x</b>
        <input|hslider min=0 max=100 value=50 />
        <input|vslider min=0 max=100 value=50 buddy="p2a-buddy" /><b id="p2a-buddy">x</b>
    </div>

    <div .hbox>
        <p>scrollbars</p>
        <widget|vscrollbar for="plaintext#lorem" />
        <widget|hscrollbar for="plaintext#lorem" />
    </div>

    <div .hbox>
        <p>dialogs</p>
        <button #info>info</button>
        <button #alert>alert</button>
        <button #error>error</button>
        <button #question>question</button>
        <button #file>select file</button>
        <button #folder>select folder</button>
    </div>

    <div .hbox>
        <p>menu</p>

        <!-- top level - menu bar, it must match ul#menu-bar selector, see std-menu.css -->
        <ul #menu-bar>
            <li>
                <caption>File</caption>
                <menu>
                    <li #menu-open>Open</li>
                    <li>Save</li>
                </menu>
            </li>
            <li>
                <caption>Edit</caption>
                <menu>
                    <li>Cut</li>
                    <li>Copy</li>
                    <li>Paste</li>
                    <li>Convert
                        <menu>
                            <li>Uppercase</li>
                            <li>Lowercase</li>
                        </menu>
                    </li>
                </menu>
            </li>
        </ul>

        <menu .bar>
            <li filename="c:\windows\notepad.exe">notepad.exe</li>
            <li filename="c:\windows\regedit.exe">regedit.exe</li>
            <li filename="c:\windows\explorer.exe">explorer.exe</li>
        </menu>

        <ul id="menu-bar"> <!-- top level - menu bar, it must match ul#menu-bar selector, see std-menu.css -->
            <li>
                Simple
                <menu class="cool">
                    <li title="Hello world!">First item (with tooltip)</li>
                    <li accesskey="^2">Second item<span class="accesskey">Ctrl+<font color="red">2</font></span></li>
                    <li>
                        Third item
                        <menu>
                            <li style="background:linear-gradient(left,yellow,red)">First sub-item</li>
                            <li>Second sub-item</li>
                        </menu>
                    </li>
                    <li accesskey="^4">Fourth item<span class="accesskey">Ctrl+<font color="red">4</font></span></li>
                </menu>
            </li>
            <li>
                Simple 2
                <menu class="cool">
                    <li>First item</li>
                    <li>Second item</li>
                    <li>Third item</li>
                </menu>
            </li>
            <li>Inputs
                <menu>
                    <li type="radio">First radio item</li>
                    <li type="radio">Second radio item</li>
                    <li type="radio">Third radio item</li>
                    <hr/>
                    <li type="check">First check item</li>
                    <li type="check">Second check item</li>
                    <li type="check">Third check item</li>
                    <hr/>
                    <li>Volume is <input type="hslider" max="10" value="0" buddy="volume-buddy" /> <b id="volume-buddy">x</b> Db</li>
                </menu>
            </li>

            <li>Complex
                <menu class="cool">
                    <li>
                        <input type="radio" />First
                        <input type="radio" />Second
                        <input type="radio" />Third
                    </li>
                    <hr/>
                    <li type="check">First check item</li>
                    <li type="check">Second check item</li>
                    <li type="check">Third check item</li>
                    <hr/>
                    <li>
                        Volume is <input type="hslider" max="10" value="0" step="0.1" buddy="volume-buddy2" /> <b id="volume-buddy2">x</b> Db
                    </li>
                    <li>
                        Value: <input type="number" size=4 step=1 minvalue=0 maxvalue=100 value="25" />
                    </li>
                    <li>
                        <button name="just-a-button">Just a button</button>
                    </li>
                    <li>dropdown select:
                        <select>
                            <option>First</option>
                            <option>Second</option>
                            <option>Third</option>
                        </select>
                    </li>
                </menu>
            </li>
        </ul>

        <button type="menu">Left click menu
            <menu class="office">
                <li title="hello!">First item</li>
                <li>Second item</li>
                <li>Third item
                    <menu>
                        <li>First sub-item</li>
                        <li>Second sub-item</li>
                    </menu>
                </li>
                <li>Fourth item</li>
            </menu>
        </button>

        <button .context-menu>Right click menu</button>
        <menu .context #context >
            <li>First item</li>
            <li>Second item</li>
            <li>Third item</li>
            <li>Fourth item</li>
            <li>
                Sub menu
                <menu>
                    <li>item</li>
                    <li>item</li>
                </menu>
            </li>
        </menu>
    </div>

    <div .hbox>
        <p>date and time</p>
        <div style="flow: horizontal; border-spacing: 1em;">
            <input|time value="now" />
            <input|time value="11:00:00" no-seconds />
        </div>
        <input|date value="2021-05-09" firstdayofweek="1" timezone="local" />
        <!-- mode="days" | "months" | "years" | "century" -->
        <input|calendar value="2021-05-09" firstdayofweek="1" mode="days" />
    </div>

    <div .hbox>
        <p>plaintext</p>
        <button #plaintext src="sciter:ux-master.css" srctype="text/css">load</button>
        <plaintext type="text/css" />
        <plaintext|text #lorem readonly spellcheck="true">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        </plaintext>
    </div>

    <div .hbox>
        <p>textarea</p>
        <textarea>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        </textarea>
    </div>

    <div .hbox>
        <p>htmlarea</p>
        <htmlarea>
           <p>paragraph</p>
           <b>bold</b>
           <i>italic</i>
        </htmlarea>
    </div>

    <div .hbox>
        <p><a href="https://lottiefiles.com/featured">animations</a></p>

        <lottie src="images/animations/loading-anim.json" autoplay loop />
        <lottie src="images/animations/icon-checked-green.json" autoplay loop />
    </div>

    <div .hbox>
        <p>video</p>
        <!-- taken from https://filesamples.com/formats/wmv -->
        <!-- sizing - string, either: "cover" or "contain" (default). -->
        <video src="videos/sample.wmv" sizing="cover" autoplay loop>cover</video>
    </div>

    <div .hbox>
        <p>output</p>
        <output|time-local format="long" />
        <output|text value="output sample value" />
        <output|integer value=4 />

        <!-- see in code how the output values get set -->
        <form #output>
            <output|text(field1) />
            <output|text(field2) />
            <output|integer(field3) />
        </form>
    </div>

    <div .hbox>
        <p>fontawesome</p>
        <i class="fas fa-star"></i>test<i class="fas fa-star"></i>
        <button><i class="fas fa-star"></i>Do it!<i class="fas fa-star"></i></button><i class="fas fa-star"></i>
    </div>

    <div .hbox>
        <p>more controls</p>
        <toolbar>
            <button />
            <button />
        </toolbar>
        <!-- more controls
        <button type="selector" />
        <input type="file-path" />
        <input type="folder-path" />
        <meter />
        -->
    </div>

</body>
</html>
